<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue'
import { useRouter } from 'vue-router'
import { useTheme } from '@/composables/useTheme'
import {
  Avatar,
  Lock,
  Loading,
  MagicStick,
  CircleCheckFilled,
  Connection,
  Stamp,
} from '@element-plus/icons-vue'

const router = useRouter()
const { themes, currentTheme, setTheme } = useTheme()

const isLogin = ref(true)
const isLoading = ref(false)
const showThemes = ref(false)

const formData = ref({
  username: '',
  email: '',
  password: '',
  confirmPassword: '',
  inviteCode: '',
})

const handleThemeChange = (themeId: string) => {
  if (currentTheme.value.id === themeId) {
    setTheme('default')
  } else {
    setTheme(themeId)
  }
}

// 模拟登录/注册过程
const handleSubmit = async () => {
  isLoading.value = true
  await new Promise((resolve) => setTimeout(resolve, 1500))
  localStorage.setItem('token', 'demo-token')
  router.push('/')
}

// 动态计算粒子位置
const getParticleStyle = (index: number) => {
  const angle = (index / 8) * Math.PI * 2
  const radius = 250 + Math.random() * 100
  return {
    left: `${50 + Math.cos(angle) * radius}px`,
    top: `${50 + Math.sin(angle) * radius}px`,
    animationDelay: `${index * 0.5}s`,
    width: `${20 + Math.random() * 30}px`,
    height: `${20 + Math.random() * 30}px`,
  }
}

// 生成装饰性数字
const generateMatrix = () => {
  return Array.from({ length: 50 }, () => Math.random().toString(2).substring(2, 10))
}

const matrix = ref(generateMatrix())
const matrixInterval = ref<number>()

onMounted(() => {
  document.addEventListener('click', closeThemePanel)
  // 使用 ref 存储定时器 ID
  matrixInterval.value = window.setInterval(() => {
    matrix.value = generateMatrix()
  }, 3000)
})

onUnmounted(() => {
  document.removeEventListener('click', closeThemePanel)
  // 清除定时器
  if (matrixInterval.value) {
    clearInterval(matrixInterval.value)
  }
})

const closeThemePanel = (event: MouseEvent) => {
  const panel = document.querySelector('.theme-panel')
  const button = document.querySelector('.theme-btn')
  if (
    panel &&
    button &&
    !panel.contains(event.target as Node) &&
    !button.contains(event.target as Node)
  ) {
    showThemes.value = false
  }
}
</script>

<template>
  <div class="auth-container">
    <div class="theme-switcher">
      <el-button
        type="text"
        class="theme-btn"
        @click="showThemes = !showThemes"
        :class="{ active: showThemes }"
      >
        <el-icon><MagicStick /></el-icon>
      </el-button>
    </div>

    <div class="theme-panel" :class="{ show: showThemes }">
      <div class="theme-options">
        <div
          v-for="theme in themes"
          :key="theme.id"
          class="theme-option"
          :class="{ active: currentTheme.id === theme.id }"
          @click="handleThemeChange(theme.id)"
        >
          <div
            class="theme-preview"
            :style="{
              background: theme.colors['bg-primary'],
              border: `1px solid ${theme.colors['border-color']}`,
            }"
          >
            <div class="preview-color" :style="{ background: theme.colors['laser-cyan'] }" />
            <div class="preview-color" :style="{ background: theme.colors['hologram-purple'] }" />
            <div class="preview-color" :style="{ background: theme.colors['supernova-orange'] }" />
          </div>
          <span class="theme-name">{{ theme.name }}</span>
        </div>
      </div>
    </div>

    <!-- 背景动效 -->
    <div class="cyber-background">
      <div v-for="i in 8" :key="i" class="cyber-particle" :style="getParticleStyle(i)"></div>
      <div class="matrix-rain">
        <div
          v-for="(line, index) in matrix"
          :key="index"
          class="matrix-line"
          :style="{ animationDelay: `${index * 0.1}s` }"
        >
          {{ line }}
        </div>
      </div>
    </div>

    <!-- 主要内容 -->
    <div class="auth-content">
      <!-- Logo部分 -->
      <div class="auth-header">
        <div class="logo-container">
          <div class="logo-hex">
            <div class="logo-inner">🌌</div>
          </div>
          <div class="logo-rings">
            <div class="ring"></div>
            <div class="ring"></div>
            <div class="ring"></div>
          </div>
        </div>
        <h1 class="cyber-text">{{ isLogin ? '时空管理局' : '新纪元登记' }}</h1>
        <p class="cyber-subtext">{{ isLogin ? '欢迎回来，探索者' : '开启你的时空探索之旅' }}</p>
      </div>

      <!-- 表单部分 -->
      <div class="auth-form">
        <div class="form-grid">
          <div class="form-field username" :class="{ expanded: !isLogin }">
            <el-input
              v-model="formData.username"
              placeholder="探索者代号"
              :maxlength="20"
              show-word-limit
            >
              <template #prefix>
                <div class="input-icon">
                  <div class="icon-circle">
                    <el-icon><Avatar /></el-icon>
                  </div>
                </div>
              </template>
            </el-input>
            <div class="field-decoration"></div>
          </div>

          <div v-if="!isLogin" class="form-field email">
            <el-input v-model="formData.email" placeholder="星际通讯地址" type="email">
              <template #prefix>
                <div class="input-icon">
                  <div class="icon-circle">
                    <el-icon><Connection /></el-icon>
                  </div>
                </div>
              </template>
            </el-input>
            <div class="field-decoration"></div>
          </div>

          <div class="form-field password">
            <el-input
              v-model="formData.password"
              type="password"
              placeholder="时空密钥"
              show-password
              :maxlength="30"
            >
              <template #prefix>
                <div class="input-icon">
                  <div class="icon-circle pulse">
                    <el-icon><Lock /></el-icon>
                  </div>
                </div>
              </template>
            </el-input>
            <div class="field-decoration"></div>
          </div>

          <div v-if="!isLogin" class="form-field confirm-password">
            <el-input
              v-model="formData.confirmPassword"
              type="password"
              placeholder="确认密钥"
              show-password
              :maxlength="30"
            >
              <template #prefix>
                <div class="input-icon">
                  <div class="icon-circle">
                    <el-icon><CircleCheckFilled /></el-icon>
                  </div>
                </div>
              </template>
            </el-input>
            <div class="field-decoration"></div>
          </div>

          <div v-if="!isLogin" class="form-field invite-code">
            <el-input v-model="formData.inviteCode" placeholder="邀请密令（选填）" :maxlength="8">
              <template #prefix>
                <div class="input-icon">
                  <div class="icon-circle">
                    <el-icon><Stamp /></el-icon>
                  </div>
                </div>
              </template>
            </el-input>
            <div class="field-decoration"></div>
          </div>
        </div>

        <div class="form-actions">
          <button class="cyber-button" @click="handleSubmit" :disabled="isLoading">
            <div class="button-bg"></div>
            <span class="button-content">
              <el-icon v-if="isLoading"><Loading /></el-icon>
              <span>{{ isLogin ? '启动探索' : '开始旅程' }}</span>
            </span>
            <div class="button-glitch"></div>
          </button>

          <div class="switch-mode">
            <span>{{ isLogin ? '初次造访？' : '已有身份？' }}</span>
            <button class="text-button" @click="isLogin = !isLogin">
              {{ isLogin ? '注册身份' : '返回登录' }}
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

/* 背景动效 */
.cyber-background {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.cyber-particle {
  position: absolute;
  background: var(--laser-cyan);
  opacity: 0.15;
  border-radius: 2px;
  animation: particleFloat 20s infinite linear;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  box-shadow: 0 0 10px var(--laser-cyan);
}

.matrix-rain {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  color: var(--laser-cyan);
  font-family: monospace;
  font-size: 12px;
  opacity: 0.15;
  display: flex;
  justify-content: space-around;
  pointer-events: none;
  will-change: transform;
}

.matrix-line {
  animation: matrixRain 3s linear infinite;
  writing-mode: vertical-rl;
  text-orientation: upright;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* 主要内容 */
.auth-content {
  width: 100%;
  max-width: 600px;
  padding: 40px;
  position: relative;
  z-index: 1;
}

/* Logo部分 */
.auth-header {
  text-align: center;
  margin-bottom: 40px;
}

.logo-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
}

.logo-hex {
  width: 100%;
  height: 100%;
  background: var(--bg-secondary);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  animation: logoFloat 3s ease-in-out infinite;
  box-shadow:
    inset 0 0 20px var(--laser-cyan),
    0 0 15px var(--laser-cyan);
}

.logo-inner {
  font-size: 48px;
  transform: scale(1.2);
}

.logo-rings {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 2px solid var(--laser-cyan);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.4;
  animation: ringPulse 3s ease-in-out infinite;
  box-shadow: 0 0 10px var(--laser-cyan);
}

.ring:nth-child(1) {
  width: 140%;
  height: 140%;
  animation-delay: 0s;
}
.ring:nth-child(2) {
  width: 160%;
  height: 160%;
  animation-delay: 0.5s;
}
.ring:nth-child(3) {
  width: 180%;
  height: 180%;
  animation-delay: 1s;
}

.cyber-text {
  font-size: 36px;
  margin: 0 0 10px;
  color: var(--text-primary);
  text-shadow:
    0 0 5px var(--laser-cyan),
    0 0 10px var(--laser-cyan),
    0 0 15px var(--laser-cyan);
  position: relative;
  font-weight: bold;
  letter-spacing: 1px;
}

.cyber-text::before {
  content: attr(data-text);
  position: absolute;
  left: 2px;
  text-shadow: 2px 0 var(--hologram-purple);
  top: 0;
  color: var(--text-primary);
  background: none;
  overflow: hidden;
  animation: glitch 3s infinite linear alternate-reverse;
}

.cyber-subtext {
  color: var(--text-primary);
  font-size: 16px;
  margin: 0;
  opacity: 0.9;
  text-shadow: 0 0 5px var(--laser-cyan);
  letter-spacing: 0.5px;
}

/* 表单部分 */
.auth-form {
  background: transparent;
  border: 1px solid rgba(var(--laser-cyan-rgb), 0.15);
  border-radius: 24px;
  padding: 30px;
  backdrop-filter: blur(15px);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 60px rgba(0, 0, 0, 0.2),
    0 0 20px rgba(var(--laser-cyan-rgb), 0.08),
    inset 0 0 30px rgba(var(--laser-cyan-rgb), 0.08);
  animation: formBreath 8s ease-in-out infinite;
}

.auth-form::before {
  content: '';
  position: absolute;
  inset: -1px;
  background: linear-gradient(
    135deg,
    var(--laser-cyan) 0%,
    var(--hologram-purple) 50%,
    var(--supernova-orange) 100%
  );
  border-radius: 25px;
  opacity: 0.1;
  z-index: 0;
  pointer-events: none;
}

.auth-form::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0.2;
  animation: formLight 12s linear infinite;
  z-index: 1;
  pointer-events: none;
  border-radius: 24px;
  border: 1px solid rgba(var(--laser-cyan-rgb), 0.15);
}

.form-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.form-field {
  position: relative;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-field.username,
.form-field.password {
  grid-column: 1 / -1;
}

.form-field.email {
  grid-column: 1 / -1;
}

.form-field::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: var(--wormhole-gradient);
  border-radius: 16px;
  opacity: 0;
  transition: all 0.4s ease;
  z-index: 0;
  transform: scale(0.98);
}

.form-field:hover::before {
  opacity: 1;
  transform: scale(1);
}

.form-field :deep(.el-input__wrapper) {
  background: rgba(var(--bg-secondary-rgb), 0.8);
  border: 1px solid rgba(var(--border-color-rgb), 0.3);
  box-shadow: none;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 14px;
  padding: 4px 15px;
  height: 50px;
  backdrop-filter: blur(5px);
  position: relative;
  z-index: 2;
}

.form-field :deep(.el-input__wrapper:hover),
.form-field :deep(.el-input__wrapper.is-focus) {
  border-color: rgba(var(--laser-cyan-rgb), 0.6);
  background: rgba(var(--bg-secondary-rgb), 0.95);
  box-shadow:
    0 0 20px rgba(var(--laser-cyan-rgb), 0.15),
    inset 0 0 10px rgba(var(--laser-cyan-rgb), 0.1);
  transform: translateY(-1px);
}

.form-field :deep(.el-input__inner) {
  color: var(--text-primary);
  font-size: 16px;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.form-field :deep(.el-input__inner::placeholder) {
  color: rgba(var(--text-secondary-rgb), 0.8);
  font-size: 15px;
  font-weight: normal;
  letter-spacing: 0.5px;
}

.form-field :deep(.el-input__count) {
  background: rgba(var(--bg-primary-rgb), 0.4);
  color: rgba(var(--text-secondary-rgb), 0.9);
  font-size: 12px;
  padding: 2px 12px;
  height: 24px;
  line-height: 20px;
  border-radius: 12px;
  border: 1px solid rgba(var(--border-color-rgb), 0.2);
  backdrop-filter: blur(5px);
  box-shadow:
    inset 0 0 5px rgba(var(--laser-cyan-rgb), 0.1),
    0 2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(-50%);
  margin-right: 8px;
}

.form-field :deep(.el-input__count-inner) {
  background: transparent;
}

.input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-right: 6px;
  position: relative;
}

.icon-circle {
  width: 36px;
  height: 36px;
  background: rgba(var(--bg-primary-rgb), 0.6);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--laser-cyan);
  font-size: 20px;
  transition: all 0.4s ease;
  position: relative;
  box-shadow: inset 0 0 10px rgba(var(--laser-cyan-rgb), 0.2);
  z-index: 3;
}

.icon-circle::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent, rgba(var(--laser-cyan-rgb), 0.1), transparent);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.icon-circle :deep(.el-icon) {
  transition: all 0.4s ease;
  position: relative;
  z-index: 1;
}

.form-field:hover .icon-circle {
  color: var(--hologram-purple);
  box-shadow:
    inset 0 0 15px rgba(var(--hologram-purple-rgb), 0.3),
    0 0 10px rgba(var(--hologram-purple-rgb), 0.2);
}

.form-field:hover .icon-circle::before {
  opacity: 1;
}

.icon-circle.pulse {
  animation: iconFloat 4s ease-in-out infinite;
}

@keyframes iconFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

/* 按钮样式 */
.cyber-button {
  width: 100%;
  height: 54px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 17px;
  font-weight: bold;
  position: relative;
  cursor: pointer;
  padding: 0;
  overflow: visible;
  border-radius: 16px;
  letter-spacing: 1px;
  transform: translateZ(0);
  will-change: transform;
}

/* 充能进度条效果 */
.button-bg {
  position: absolute;
  inset: -2px;
  background: var(--bg-primary);
  border-radius: 17px;
  overflow: hidden;
  z-index: 1;
}

.button-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    var(--laser-cyan),
    var(--hologram-purple),
    var(--supernova-orange)
  );
  transform: translateX(-101%);
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  border-radius: 17px;
}

.cyber-button:hover .button-bg::before {
  transform: translateX(0);
}

/* 虚线边框能量循环 */
.button-glitch {
  position: absolute;
  inset: -2px;
  border-radius: 17px;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(
    135deg,
    var(--laser-cyan),
    var(--hologram-purple),
    var(--supernova-orange)
  );
}

.button-glitch::after {
  content: '';
  position: absolute;
  inset: 2px;
  background: var(--bg-primary);
  border-radius: 15px;
  z-index: 1;
}

/* 按钮内容样式 */
.button-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  background: transparent;
  padding: 0 24px;
  color: inherit;
  text-shadow: 0 0 10px rgba(var(--text-primary-rgb), 0.3);
}

.cyber-button:hover .button-content {
  color: var(--bg-primary);
  text-shadow: none;
  mix-blend-mode: difference;
}

/* Loading动画 */
.button-content :deep(.el-icon) {
  font-size: 22px;
}

.cyber-button[disabled] .button-content :deep(.el-icon) {
  animation: loadingSpin 1s linear infinite;
}

@keyframes loadingSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 禁用状态 */
.cyber-button:disabled {
  opacity: 0.8;
  cursor: not-allowed;
}

.cyber-button:disabled .button-bg::before {
  display: none;
}

.cyber-button:disabled .button-glitch::before {
  animation: none;
  opacity: 0;
}

.switch-mode {
  margin-top: 20px;
  text-align: center;
  color: var(--text-primary);
  font-size: 15px;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 10;
  text-shadow: 0 0 5px rgba(var(--laser-cyan-rgb), 0.3);
}

.text-button {
  background: none;
  border: none;
  color: var(--laser-cyan);
  cursor: pointer;
  font-size: inherit;
  margin-left: 8px;
  position: relative;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(var(--laser-cyan-rgb), 0.4);
  transition: all 0.4s ease;
  padding: 4px 8px;
  z-index: 10;
}

.text-button::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--laser-cyan);
  transform: scaleX(0);
  transition: all 0.4s ease;
  box-shadow: 0 0 8px rgba(var(--laser-cyan-rgb), 0.4);
}

.text-button:hover {
  color: var(--hologram-purple);
  text-shadow:
    0 0 10px rgba(var(--hologram-purple-rgb), 0.5),
    0 0 20px rgba(var(--hologram-purple-rgb), 0.3);
  letter-spacing: 1px;
  background: rgba(var(--hologram-purple-rgb), 0.1);
  border-radius: 4px;
}

.text-button:hover::before {
  transform: scaleX(1);
  background: var(--hologram-purple);
  box-shadow: 0 0 10px rgba(var(--hologram-purple-rgb), 0.5);
}

@keyframes formBreath {
  0%,
  100% {
    transform: scale(1);
    box-shadow:
      0 0 60px rgba(0, 0, 0, 0.2),
      0 0 20px rgba(var(--laser-cyan-rgb), 0.08),
      inset 0 0 30px rgba(var(--laser-cyan-rgb), 0.08);
  }
  50% {
    transform: scale(1.002);
    box-shadow:
      0 0 70px rgba(0, 0, 0, 0.25),
      0 0 25px rgba(var(--laser-cyan-rgb), 0.1),
      inset 0 0 35px rgba(var(--laser-cyan-rgb), 0.1);
  }
}

@keyframes formLight {
  0% {
    transform: translateX(-100%) rotate(45deg);
  }
  100% {
    transform: translateX(100%) rotate(45deg);
  }
}

/* 动画 */
@keyframes particleFloat {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  100% {
    transform: translate(-100px, -100px) rotate(360deg);
  }
}

@keyframes matrixRain {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}

@keyframes logoFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes ringPulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.4;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0.1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.4;
  }
}

@keyframes glitch {
  0% {
    clip-path: inset(40% 0 61% 0);
  }
  20% {
    clip-path: inset(92% 0 1% 0);
  }
  40% {
    clip-path: inset(43% 0 1% 0);
  }
  60% {
    clip-path: inset(25% 0 58% 0);
  }
  80% {
    clip-path: inset(54% 0 7% 0);
  }
  100% {
    clip-path: inset(58% 0 43% 0);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .auth-content {
    padding: 20px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-field {
    grid-column: 1 / -1 !important;
  }

  .cyber-text {
    font-size: 28px;
  }
}

/* 主题切换按钮 */
.theme-switcher {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

.theme-btn {
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  border-radius: 8px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  background: var(--bg-secondary);
}

.theme-btn:hover,
.theme-btn.active {
  color: var(--hologram-purple);
  background: var(--bg-card);
  box-shadow: 0 0 10px var(--hologram-purple);
}

.theme-panel {
  position: fixed;
  top: 70px;
  right: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 15px;
  width: 280px;
  transform: translateX(120%);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.theme-panel.show {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

.theme-option {
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.theme-option:hover {
  background: var(--bg-secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.theme-option.active {
  background: var(--bg-secondary);
  border: 1px solid var(--laser-cyan);
}

.theme-option.active:hover {
  border-color: var(--supernova-orange);
  box-shadow: 0 0 15px var(--supernova-orange);
}

.theme-preview {
  height: 60px;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.theme-preview::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.theme-option:hover .theme-preview::before {
  transform: translateX(100%);
}

.preview-color {
  height: 6px;
  border-radius: 3px;
  transition: all 0.3s ease;
}

.theme-option:hover .preview-color {
  transform: scaleX(1.05);
}

.theme-name {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  display: block;
  transition: all 0.3s ease;
}

.theme-option:hover .theme-name {
  color: var(--text-primary);
}

.theme-option.active .theme-name {
  color: var(--laser-cyan);
  text-shadow: 0 0 8px var(--laser-cyan);
}

.theme-option.active:hover .theme-name {
  color: var(--supernova-orange);
  text-shadow: 0 0 8px var(--supernova-orange);
}

@media (max-width: 768px) {
  .theme-panel {
    width: calc(100% - 40px);
    right: 20px;
    left: 20px;
    transform: translateY(-120%);
    opacity: 0;
  }

  .theme-panel.show {
    transform: translateY(0);
    opacity: 1;
  }
}
</style>
